package chess

import "errors"

// 吃子
func (p *Piece) eat(piece *Piece) (string, error) {
	delete(p.chessboard.M, p.Point)
	str := p.Name + "吃了" + piece.Name
	switch piece.piece.(type) {
	case King:
		err := errors.New(p.Color + "胜利")
		return str, err
	}
	p.Row = piece.Row
	p.Line = piece.Line
	piece.Status = false
	p.chessboard.M[piece.Point] = p
	return str, nil
}
